4 // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
6 // The use and distribution terms for this software are contained in the file
7 // named license.txt, which can be found in the root of this distribution.
8 // By using this software in any fashion, you are agreeing to be bound by the
9 // terms of this license.
11 // You must not remove this notice, or any other, from this software.
16 namespace Microsoft
.JScript
{
19 using System
.Collections
;
20 using System
.Diagnostics
;
21 using System
.Reflection
;
23 public sealed class EnumeratorConstructor
: ScriptFunction
{
24 internal static readonly EnumeratorConstructor ob
= new EnumeratorConstructor();
26 private EnumeratorPrototype originalPrototype
;
28 internal EnumeratorConstructor()
29 : base(FunctionPrototype
.ob
, "Enumerator", 1) {
30 this.originalPrototype
= EnumeratorPrototype
.ob
;
31 EnumeratorPrototype
._constructor
= this;
32 this.proto
= EnumeratorPrototype
.ob
;
35 internal EnumeratorConstructor(LenientFunctionPrototype parent
, LenientEnumeratorPrototype prototypeProp
)
36 : base(parent
, "Enumerator", 1) {
37 this.originalPrototype
= prototypeProp
;
38 prototypeProp
.constructor
= this;
39 this.proto
= prototypeProp
;
40 this.noExpando
= false;
43 internal override Object
Call(Object
[] args
, Object thisob
){
47 internal override Object
Construct(Object
[] args
){
48 return this.CreateInstance(args
);
51 [JSFunctionAttribute(JSFunctionAttributeEnum
.HasVarArgs
)]
52 public new EnumeratorObject
CreateInstance(params Object
[] args
){
53 if (args
.Length
!= 0){
55 if (obj
is IEnumerable
)
56 return new EnumeratorObject(this.originalPrototype
, (IEnumerable
)obj
);
57 throw new JScriptException(JSError
.NotCollection
);
59 return new EnumeratorObject(this.originalPrototype
, (IEnumerable
)null);
62 public Object
Invoke(){